package cn.doctor.assistant.pad.ui;

import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

import cn.doctor.assistant.pad.MyApplication;

/**
 * Created by jiaolf on 2016/3/31.
 */
public class SpinnerHelper {

    public static void init(Spinner spinner, String[] items, AdapterView.OnItemSelectedListener listener) {
        ArrayAdapter<String> adapter = new ArrayAdapter<>(
                MyApplication.getInstance().getCurrentActivity(),
                android.R.layout.simple_spinner_item, items);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);
        if (listener != null) {
            spinner.setOnItemSelectedListener(listener);
        }
    }

}
